﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OracleClient;
using database.Entities;

namespace database.DAOImpl
{
    class StoreStaffDAOImpl
    {
        public StoreStaffDAOImpl()
        {

        }

        public void insertIntoStoreStaff(Storesstaff storeStaff)
        {
            DBUtils util = new DBUtils();
            util.ConnOpen();
            string sql = "insert into STORES_STAFF (NAME, POSITION, AGE, SALARY, STOREID) values (:name, :position, :age, :salary, :storeId)";
            OracleCommand cmd = new OracleCommand(sql, util.getConn());
            OracleParameter parName = new OracleParameter(":name", storeStaff.Name);
            OracleParameter parPosition = new OracleParameter(":position", storeStaff.Position);
            OracleParameter parAge = new OracleParameter(":age", storeStaff.Age);
            OracleParameter parSalary = new OracleParameter(":salary", storeStaff.Salary);
            OracleParameter parStoreId = new OracleParameter(":storeId", storeStaff.StoreId);

            cmd.Parameters.Add(parName);
            cmd.Parameters.Add(parPosition);
            cmd.Parameters.Add(parAge);
            cmd.Parameters.Add(parSalary);
            cmd.Parameters.Add(parStoreId);

            cmd.CommandText = sql;
            cmd.ExecuteNonQuery();
            util.ConnClose();
        }
    }
}
